
/*
 * Written by Rossi Kamal
 * Date 2011.01.06
 * 
 */

package net.m2m.policycompiler.translation;

import java.beans.XMLEncoder;
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;

public class M2MPolicyTranslate {

	public M2MPolicyTranslate(String policyName,String policyDefinedBy, 
			String eventName, String  M2MService, String M2MDevice, 
			String condition1, 
			String condition2, 
			String condition3, 
			String action1, 
			String action2, 
			String action3, 
			String policyDescription)
	{	
		
		try {

			
			M2MPolicy m2mP=new M2MPolicy();
			m2mP.setPolicyName(policyName);
			m2mP.setPolicyDefinedBy(policyDefinedBy);
			m2mP.setEventName(eventName);
			m2mP.setM2MDevice(M2MDevice);
			m2mP.setM2MService(M2MService);
			m2mP.setcondition1(condition1);
			m2mP.setcondition2(condition2);
			m2mP.setcondition3(condition3);
			m2mP.setaction1(action1);
			m2mP.setaction2(action2);
			m2mP.setaction3(action3);
			
			XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
					new FileOutputStream("/home/Siddiqui/workspace/M2M/policy_xml/policy.xml")));
			encoder.writeObject(m2mP);
			encoder.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		
	}
	
	public static void main(String[] args) {
		M2MPolicyTranslate m2mPT=new M2MPolicyTranslate(
				  "String policyName",
				  "String policyDefinedBy","String policyDescription",
				   
				   "String eventName", 
				   "String  M2MService",
				   "String M2MDevice",
				   
				   "String condition1",
				   "String condition2",
				   "String condition3",
				   
				   "String action1",
				   "String action2",
				   "String action3");
	}
}
